

#include "switchCameraNode.h"
#include "control.h"
#include "renderer.h"
#include "input.h"

SwitchCameraNode::SwitchCameraNode(){
    name="SwitchCameraNode";
    cameraActor=NULL;

    listType.push_back("15PickWorldButton");
    listName.push_back("cameraActor");

    color=Vector4f(0.5,0.5,0.5,1.0);
    registerProperties();
    controller=input->controller;
    }

SwitchCameraNode::~SwitchCameraNode(){}

void SwitchCameraNode::registerProperties(){

Node::registerProperties();
createMemberID("CAMERAACTOR",&cameraActor,this);
}

void SwitchCameraNode::start(){
    cameraActor->bHidden=true;
    controller->state=MOVECAMERASTATE;
    Node::start();
}

void SwitchCameraNode::stop(){

    controller->state=MOVECURSORSTATE;
    cameraActor->bHidden=false;
    Node::stop();
    input->controller->controlledActor=input->controller;
    input->controller->processMove(0);
}

void SwitchCameraNode::execute(){
    input->controller->controlledActor=cameraActor;
    Node::nextNode();
    }


void SwitchCameraNode::trigger(Actor * other){

    if (other==listButton[0] && input->worldTarget){
        cameraActor=input->worldTarget;
        cout << "SwitchCameraNode triggered!!!" << cameraActor->name << endl;
        }
    }

void SwitchCameraNode::update(double deltaTime){
    Node::update(deltaTime);
    }

void SwitchCameraNode::create(){renderer->addNode(this);}
